{template '_header'}
<div class="page-heading">
    <h2>分类管理</h2>
</div>

<form action="" method="post" class="form-validate">

    <table class="table table-hover  table-responsive">
        <thead class="navbar-inner">
        <tr>
            <th style="width:60px;">ID</th>
            <th>分类名称</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id='tbody-items'>
        {loop $list $row}
        <tr>
            <td>{$row['id']}</td>
            <td>
                {ifp 'seckill.category.edit'}
                <input type="text" class="form-control" name="catname[{$row['id']}]" value="{$row['name']}">
                {else}
                {$row['name']}
                {/if}
            </td>
            <td>
                {ifp 'seckill.category.delete'}<a data-toggle="ajaxRemove" href="{php echo webUrl('seckill/category/delete', array('id' => $row['id']))}"class="btn btn-default btn-sm" data-confirm="确认删除此分类?"><i class="fa fa-trash"></i> 删除</a>{/if}
            </td>
            </td>
        </tr>
        {/loop}
        </tbody>

        <tr>
            <td colspan="3">
                {ifp 'seckill.category.add'}
                <input type="button" class="btn btn-default" value="添加分类" onclick='addCategory()'>
                {/if}
                {ifp 'seckill.category.edit|seckill.category.add'}
                <input type="submit" class="btn btn-primary" value="保存分类">
                {/if}

            </td>
        </tr>
    </table>
    {$pager}


</form>
<script>
    function addCategory(){
        var html ='<tr>';
        html+='<td><i class="fa fa-plus"></i></td>';
        html+='<td>';
        html+='<input type="text" class="form-control" name="catname_new[]" value="">';
        html+='</td><td></td></tr>';;
        $('#tbody-items').append(html);
    }

</script>

{template '_footer'}

